#include "observer.h"
#include <iostream>

using namespace observer;

void Subject::registerObserver(Observer* o)
{
   this->m_obj.push_back(o);
}

void Subject::removeObserver(Observer* o)
{
    this->m_obj.remove(o);
}

void Subject::notifyObserver()
{
    std::list<Observer*>::iterator it = this->m_obj.begin();
    for (; it != this->m_obj.end(); ++it)
    {
         (*it)->update();
    }
}

////////////////////////////////////////////
void CurrentConditionDisplay::update()
{
    this->display();
}

void CurrentConditionDisplay::display()
{
    std::cout << "CurrentConditionDisplay display!" << std::endl;
}

void StatisticsDisplay::update()
{
    this->display();
}

void StatisticsDisplay::display()
{
    std::cout << "StatisticsDisplay display!" << std::endl;
}

void ForecastDisplay::update()
{
    this->display();
}

void ForecastDisplay::display()
{
    std::cout << "ForecastDisplay display!" << std::endl;
}

void ThirdPartyDisplay::update()
{
    this->display();
}

void ThirdPartyDisplay::display()
{
    std::cout << "ThirdPartyDisplay display!" << std::endl;
}
